package cn.xing.managementSystem.config;

import cn.xing.managementSystem.interceptor.AuthenticationInterceptor;
import cn.xing.managementSystem.interceptor.CorsInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * @author cuixing
 * @package cn.xing.managementSystem.config
 * @class WebAppConfig
 * @email xing.cui@magicwindow.cn
 * @date 2018/4/21 下午8:50
 * @description
 */
@Configuration
public class WebAppConfig extends WebMvcConfigurerAdapter {

    @Autowired
    private AuthenticationInterceptor authenticationInterceptor;

    @Autowired
    private CorsInterceptor corsInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(authenticationInterceptor).excludePathPatterns("/login", "/toLogin", "/showImage", "/v1/**");
        registry.addInterceptor(corsInterceptor).addPathPatterns("/**");
        super.addInterceptors(registry);
    }
}